//
//  TipTool.m
//  O2O-AccountManager
//
//  Created by 李良 on 16/2/16.
//  Copyright © 2016年 liliang. All rights reserved.
//

#import "TipTool.h"
#import "LQPopUpView.h"
#import "DLLoadingRunTip.h"
#import "AlertView.h"
#import <MBProgressHUD/MBProgressHUD.h>


NSArray<UIImage *> *loadingGifImgArray = nil;//加载gif图片数组
UIColor *kLoadingBackgroundColor = nil;//等待加载背景色
UIColor *kLoadingTextColor = nil;//等待加载字体色
NSTimeInterval kLoadingTimeDuration = 0.9f;//等待动画播放一次的时长

#define kContentColor  [UIColor darkTextColor]//默认文字颜色颜色
#define kColor  [UIColor redColor]//默认背景颜色


@interface Hud :NSObject
@property (nonatomic ,strong)MBProgressHUD *hud;
@property (nonatomic ,strong)DLLoadingRunTip *loadingView;
@property (nonatomic,copy)NSString *customImageName;
@end
@implementation Hud

+ (instancetype)sharedHud {
    static Hud* dao = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        dao = [[Hud alloc] init];
    });
    
    return dao;
}
@end

typedef NS_ENUM(NSInteger, SelectBtnType){
    SelectBtnTypeCancel = 0,
    SelectBtnTypeConfirm,
};

@interface TipTool ()

@end
@implementation TipTool



+(void)showTipWithMsg:(NSString*)msg superView:(UIView *)superVie style:(DGGTipStyle)style
{
    if ([NSString isEmpty:msg]) {
        return;
    }
    [TipTool hideTipView];
    
    [Hud sharedHud].hud =[MBProgressHUD showHUDAddedTo:superVie animated:YES];
    [Hud sharedHud].hud.label.text = msg;
    [Hud sharedHud].hud.label.font = [UIFont fontWithName:@"PingFang-SC-Regular" size:14.0];
    [Hud sharedHud].hud.label.numberOfLines= 0;
    [Hud sharedHud].hud.removeFromSuperViewOnHide = YES;
    [Hud sharedHud].hud.margin = 8;
    [Hud sharedHud].hud.contentColor = [UIColor colorWithHex:0xE0E0E0];
    [Hud sharedHud].hud.bezelView.backgroundColor = [UIColor clearColor];
    [Hud sharedHud].hud.bezelView.layer.backgroundColor = [UIColor clearColor].CGColor;
    [Hud sharedHud].hud.bezelView.color = [UIColor clearColor];
    for (UIView *subView in [Hud sharedHud].hud.bezelView.subviews) {
        if ([subView isKindOfClass:[UIVisualEffectView class]]) {
            UIVisualEffectView *bView = (UIVisualEffectView*)subView;
            bView.contentView.backgroundColor =[UIColor colorWithHexString:@"#000000"];
            bView.contentView.alpha = 0.7;
//            for (UIView *sub in subView.subviews) {
//                sub.backgroundColor = [UIColor colorWithHexString:@"#000000"];
//                sub.alpha = 0.7;
//            }
        }
    }
    if (style == DGGTipStyle_Msg) {
        [Hud sharedHud].hud.mode = MBProgressHUDModeText;
    }else
    {
        UIImage *image = nil;
        
        switch (style) {
            case DGGTipStyle_Successful:
            {
                
                image = [[DLThemeAdapter shareInstance] dynamicImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_chenggong")) darkImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_chenggong_dark"))];
            }
                break;
            case DGGTipStyle_Error:
            {
                image = [[DLThemeAdapter shareInstance] dynamicImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_shibai")) darkImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_shibai_dark"))];
            }
                break;
            case DGGTipStyle_Warning:
            {
                image = [[DLThemeAdapter shareInstance] dynamicImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_jinggao")) darkImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_jinggao_dark"))];
            }
                break;
            case DGGTipStyle_Prompt:
            {
                image = [[DLThemeAdapter shareInstance] dynamicImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_tishi")) darkImage:IMAGE_NAME(kDLUIKitImageName(@"img_toast_tishi_dark"))];
            }
                break;
            case DGGTipStyle_Custom:
            {
                image = IMAGE_NAME([Hud sharedHud].customImageName);
                
            }
                break;
                
            default:
                break;
        }
        if (image) {
            [Hud sharedHud].hud.margin = 20;
            [Hud sharedHud].hud.mode = MBProgressHUDModeCustomView;
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 36, 36)];
            imageView.image = image;
            NSString *msgText = msg;
            if (msg.length >= 7) {
                msgText = [[[msg substringToIndex:7] stringByAppendingString:@"\n"] stringByAppendingString:[msg substringFromIndex:7]];
            }
            [Hud sharedHud].hud.label.text = msgText;
            [Hud sharedHud].hud.customView = imageView;
        }else
        {
            [Hud sharedHud].hud.mode = MBProgressHUDModeText;
        }
    }
    [[Hud sharedHud].hud showAnimated:YES];
    [[Hud sharedHud].hud hideAnimated:YES afterDelay:2];
}

+ (void)showMasTipWithMsg:(NSString *)msg details:(NSString *)details style:(DGGTipStyle)style delay:(NSTimeInterval)delay{
    [UIColor whiteColor];
    if ([NSString isEmpty:msg]) {
        return;
    }
    [TipTool hideTipView];
    [Hud sharedHud].hud =[MBProgressHUD showHUDAddedTo:kApplicationWindow animated:YES];
    [Hud sharedHud].hud.label.text = msg;
    [Hud sharedHud].hud.label.textColor = [UIColor groupTableViewBackgroundColor];
    [Hud sharedHud].hud.label.numberOfLines= 0;
    [Hud sharedHud].hud.detailsLabel.text = details;
    [Hud sharedHud].hud.detailsLabel.numberOfLines= 0;
    [Hud sharedHud].hud.removeFromSuperViewOnHide = YES;
    if ([DLThemeAdapter shareInstance].isDark) {
        [Hud sharedHud].hud.bezelView.backgroundColor = [UIColor clearColor];
        [Hud sharedHud].hud.bezelView.layer.backgroundColor = [UIColor clearColor].CGColor;
        [Hud sharedHud].hud.bezelView.color = [UIColor clearColor];
        for (UIView *subView in [Hud sharedHud].hud.bezelView.subviews) {
            if ([subView isKindOfClass:[UIVisualEffectView class]]) {
                for (UIView *sub in subView.subviews) {
                    sub.backgroundColor = [UIColor colorWithHexString:@"#000000"];
                    sub.alpha = 0.7;
                }
            }
        }
    }
    //    [Hud sharedHud].hud.contentColor = kContentColor;
    if (style == DGGTipStyle_Msg) {
        [Hud sharedHud].hud.mode = MBProgressHUDModeText;
    }else{
        UIImage *image = nil;
        switch (style) {
            case DGGTipStyle_Successful:{
//                image = IMAGE_NAME(@"TipTool_bounced_state_successfu");
            }break;
            case DGGTipStyle_Error:{
//                image = IMAGE_NAME(@"TipTool_bounced_state_failure");
            }break;
            case DGGTipStyle_Warning:{
//                image = IMAGE_NAME(@"TipTool_bounced_state_warning");
            }break;
            case DGGTipStyle_Prompt:{
//                image = IMAGE_NAME(@"TipTool_bounced_state_prompt");
            }break;
            case DGGTipStyle_Custom:{
                image = IMAGE_NAME([Hud sharedHud].customImageName);
            }break;
            default:break;
        }
        if (image) {
            [Hud sharedHud].hud.mode = MBProgressHUDModeCustomView;
            [Hud sharedHud].hud.customView = [[UIImageView alloc] initWithImage:image];
        }else{
            [Hud sharedHud].hud.mode = MBProgressHUDModeText;
        }
    }
    [[Hud sharedHud].hud showAnimated:YES];
    [[Hud sharedHud].hud hideAnimated:YES afterDelay:(delay > 0 ? delay : 2)];
}

+(void)showMasTip:(NSString *)text superView:(UIView *)superVie
{
    [self showTipWithMsg:text superView:superVie style:DGGTipStyle_Msg];
}
+(void)showMasTip:(NSString *)text
{
    NSString *msgText = text;
    if (text.length >= 14) {
        msgText = [[[text substringToIndex:14] stringByAppendingString:@"\n"] stringByAppendingString:[text substringFromIndex:14]];
    }
    [self showMasTip:msgText superView:kApplicationWindow];
}

+(void)showMasErrorTip:(NSString *)text superView:(UIView *)superVie
{
    [self showTipWithMsg:text superView:superVie style:DGGTipStyle_Error];
}
+(void)showMasErrorTip:(NSString *)text
{
    [self showMasErrorTip:text superView:kApplicationWindow];
}
+(void)showMasSuccessfulTip:(NSString *)text superView:(UIView *)superVie
{
    
    [self showTipWithMsg:text superView:superVie style:DGGTipStyle_Successful];
    
}
+(void)showMasSuccessfulTip:(NSString *)text
{
    NSString *msgText = text;
    if (text.length >= 7) {
        msgText = [[[text substringToIndex:7] stringByAppendingString:@"\n"] stringByAppendingString:[text substringFromIndex:7]];
    }
    [self showMasSuccessfulTip:msgText superView:kApplicationWindow];
}
+(void)showWarningTip:(NSString *)text superView:(UIView *)superVie
{
    
    [self showTipWithMsg:text superView:superVie style:DGGTipStyle_Warning];
    
}
+(void)showWarningTip:(NSString *)text
{
    [self showWarningTip:text superView:kApplicationWindow];
}

+(void)showPromptTip:(NSString *)text superView:(UIView *)superVie
{
    
    [self showTipWithMsg:text superView:superVie style:DGGTipStyle_Prompt];
    
}
+(void)showPromptTip:(NSString *)text
{
    [self showPromptTip:text superView:kApplicationWindow];
}
+(void)showCustomTip:(NSString *)text superView:(UIView *)superVie image:(NSString *)image
{
    if ([NSString isEmpty:image]) {
        return;
    }
    [Hud sharedHud].customImageName = image;
    [self showTipWithMsg:text superView:superVie style:DGGTipStyle_Custom];
    
}

+(void)showCustomTip:(NSString *)text image:(NSString *)image
{
    [self showCustomTip:text superView:kApplicationWindow image:image];
}

+ (void)showLodingTipsuperView:(UIView *)superView
{
    [TipTool showLodingTip:@"" superView:superView];
}
+ (void)showLodingTip
{
    [TipTool showLodingTip:@"" superView:kApplicationWindow];
}

+ (void)showLodingTip:(NSString *)text superView:(UIView *)superView
{
    
    [TipTool hideTipView];
    [Hud sharedHud].hud =[MBProgressHUD showHUDAddedTo:superView animated:YES];
    if (kLoadingBackgroundColor) {
        [Hud sharedHud].hud.bezelView.color = kLoadingBackgroundColor;
    } else {
        [Hud sharedHud].hud.bezelView.color = [UIColor clearColor];
    }
    if (kLoadingTextColor) {
        [Hud sharedHud].hud.contentColor = kLoadingTextColor;
    } else {
        [Hud sharedHud].hud.contentColor = kContentColor;
    }
    [Hud sharedHud].hud.label.text = text;
    [Hud sharedHud].hud.label.textColor = [UIColor groupTableViewBackgroundColor];
    [Hud sharedHud].hud.label.numberOfLines = 0 ;
    [Hud sharedHud].hud.removeFromSuperViewOnHide = YES;
    [Hud sharedHud].hud.mode = MBProgressHUDModeCustomView;
    if([DLThemeAdapter shareInstance].isDark){
        [Hud sharedHud].hud.bezelView.backgroundColor = [UIColor clearColor];
        [Hud sharedHud].hud.bezelView.layer.backgroundColor = [UIColor clearColor].CGColor;
        [Hud sharedHud].hud.bezelView.color = [UIColor clearColor];
        for (UIView *subView in [Hud sharedHud].hud.bezelView.subviews) {
            if ([subView isKindOfClass:[UIVisualEffectView class]]) {
                for (UIView *sub in subView.subviews) {
                    sub.backgroundColor = [UIColor colorWithHexString:@"#000000"];
                    sub.alpha = 0.7;
                }
            }
        }
    }
    
    UIImageView *gifView =  [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 90, 90)];
    if (loadingGifImgArray && loadingGifImgArray.count > 0) {
        gifView.animationImages = loadingGifImgArray;
    }
    gifView.animationDuration = kLoadingTimeDuration;
    [gifView startAnimating];
    
    
    
     [Hud sharedHud].hud.customView =gifView;
//    [[Hud sharedHud].hud hideAnimated:YES afterDelay:15];
}

+ (void)hideTipView
{
    if  ([Hud sharedHud].hud != nil ){
        
        [[Hud sharedHud].hud hideAnimated:YES];
        [Hud sharedHud].hud = nil;
    }
    if  ([Hud sharedHud].loadingView != nil ){
        [[Hud sharedHud].loadingView dismiss];
        [Hud sharedHud].loadingView = nil;
    }
}

+(LQPopUpView*)popUpViewWithTitle:(NSString *)title message:(NSString*)message
{
    LQPopUpView *popUpView = [[LQPopUpView alloc] initWithTitleConfiguration:^(TitleConfiguration *configuration) {
        configuration.text = title;
        configuration.fontSize = 18.0f;
        configuration.textColor = [[DLThemeAdapter shareInstance] dynamicColor:[UIColor colorWithHex:0x333333] darkColor:[UIColor colorWithHex:0xE0E0E0]];
    } messageConfiguration:^(MessageConfiguration *configuration) {
        configuration.text = message;
        configuration.fontSize = 14.0f;
        configuration.bottom = 25.0;
        configuration.textColor = [[DLThemeAdapter shareInstance] dynamicColor:[UIColor colorWithHex:0x333333] darkColor:[UIColor colorWithHex:0xE0E0E0]];
    }];
    return popUpView;
}

+(void)showAlertViewWithTitle:(NSString*)title message:(NSString*)message btns:(NSArray*)btns block:(void(^)(NSInteger index))block{
    LQPopUpView *popUpView = [self popUpViewWithTitle:title message:message];
       for (int i = 0; i<btns.count; i++) {
           
           NSString *itemTitle = btns[i];
           NSInteger style = LQPopUpBtnStyleDefault;
           if (i == 0 && btns.count > 1){
               style = LQPopUpBtnStyleCancel;
               popUpView.btnStyleCancelTextColor = [UIColor colorWithHex:0x999999];
           }else{
               style = LQPopUpBtnStyleDefault;
               popUpView.btnStyleDefaultTextColor = [UIColor colorWithHex:0x1CBEBC];
           }
           
           [popUpView addBtnWithTitle:itemTitle type:style handler:^{
               if (block) {
                   block(i);
               }
           }];
           
       }
       
       UIWindow *window = kApplicationWindow;
       [window endEditing:YES];
    

                [popUpView showInView:window preferredStyle:LQPopUpViewStyleAlert];
           for ( id view  in window.rootViewController.view.subviews) {
               if ([view isKindOfClass:NSClassFromString(@"ZLPhotoActionSheet")] ||[view isKindOfClass:NSClassFromString(@"CocoaHTTPServerView")]||[view isKindOfClass:NSClassFromString(@"MyActionSheet")]) {
                   [window bringSubviewToFront:view];
               }
           }
}

+(void)showAlertViewWithTitle:(NSString*)title message:(NSString*)message btns:(NSArray <UIColor*>*)btns colors:(NSArray *)colors block:(void(^)(NSInteger index))block{
    
    LQPopUpView *popUpView = [self popUpViewWithTitle:title message:message];
    for (int i = 0; i<btns.count; i++) {
        
        NSString *itemTitle = btns[i];
        NSInteger style = LQPopUpBtnStyleDefault;
        if (i == 0 && btns.count > 1){
            style = LQPopUpBtnStyleCancel;
            popUpView.btnStyleCancelTextColor = (colors !=nil && colors.count > 1) ? colors[0] : [UIColor colorWithHex:0x999999];
        }else{
            style = LQPopUpBtnStyleDefault;
            popUpView.btnStyleDefaultTextColor = (colors !=nil && colors.count > 0) ? colors[i] : [UIColor colorWithHex:0x1CBEBC];
        }
        
        [popUpView addBtnWithTitle:itemTitle type:style handler:^{
            if (block) {
                block(i);
            }
        }];
        
    }
    
    UIWindow *window = kApplicationWindow;
    [window endEditing:YES];
 

             [popUpView showInView:window preferredStyle:LQPopUpViewStyleAlert];
        for ( id view  in window.rootViewController.view.subviews) {
            if ([view isKindOfClass:NSClassFromString(@"ZLPhotoActionSheet")] ||[view isKindOfClass:NSClassFromString(@"CocoaHTTPServerView")]||[view isKindOfClass:NSClassFromString(@"MyActionSheet")]) {
                [window bringSubviewToFront:view];
            }
        }
    
}

+(void)showAlertTextFieldViewWithTitle:(NSString*)title message:(NSString*)message btns:(NSArray*)btns placeholders:(NSArray *)placeholders block:(void(^)(NSInteger index , NSArray *texts))block
{
    
    
    LQPopUpView *popUpView = [self popUpViewWithTitle:title message:message];
    for (int i = 0 ; i<placeholders.count; i++) {
        [popUpView addTextFieldWithPlaceholder:placeholders[i] text:nil secureEntry:NO];
        
    }
    __weak typeof(LQPopUpView) *weakPopUpView = popUpView;
    for (int i = 0; i<btns.count; i++) {
        NSString *itemTitle = btns[i];
        NSInteger style = LQPopUpBtnStyleDefault;
        if ([itemTitle isEqualToString:@"确认删除"]) {
            style = LQPopUpBtnStyleDestructive;
            
        }else if ([itemTitle isEqualToString:@"取消"])
        {
            style = LQPopUpBtnStyleCancel;
        }
        
        
        [popUpView addBtnWithTitle:itemTitle type:style handler:^{
            NSMutableArray *textArray = @[].mutableCopy;
            for (UITextField *textField in weakPopUpView.textFieldArray) {
                if ([NSString isEmpty:textField.text]) {
                    [textArray addObject:@""];
                }else
                {
                    [textArray addObject:textField.text.trimString];
                }
                
            }
            block(i,textArray);
        }];
        
    }
    
    dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW,  0.5* NSEC_PER_SEC);
    dispatch_after(when, dispatch_get_main_queue(), ^{
        if (popUpView.textFieldArray.count>0) {
            [popUpView.textFieldArray[0] becomeFirstResponder];
            
        }
    });
    
    
    UIWindow *window = kApplicationWindow;
    if (window.rootViewController.presentedViewController) {
        [popUpView showInView:window.rootViewController.presentedViewController.view preferredStyle:LQPopUpViewStyleAlert];
        
    }else
    {
        [popUpView showInView:window.rootViewController.view preferredStyle:LQPopUpViewStyleAlert];
        
    }
    
    
}

+ (void)alertWithMessage:(NSString *)message
{
    [self showAlertViewWithTitle:nil message:message btns:@[@"确定"] block:nil];
}

+ (void)alertWithMessage:(NSString *)message block:(dispatch_block_t)block
{
    [self showAlertViewWithTitle:@"提示" message:message btns:@[@"取消", @"确定"] block:^(NSInteger index) {
        if (index == 1) {
            if (block) {
                block();
            }
        }
    }];
}

+(void)showiPadSheetViewWithTitle:(NSString*)title message:(NSString*)message  btns:(NSArray*)btns view:(UIView*)view block:(void(^)(NSInteger index))block{
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet];
    UIPopoverPresentationController *popover = vc.popoverPresentationController;
    
    for (int i = 0; i<btns.count; i++) {
        NSInteger type = UIAlertActionStyleDefault;
        
        UIAlertAction *alert = [UIAlertAction actionWithTitle:btns[i] style:type handler:^(UIAlertAction * _Nonnull action) {
            if (block) {
                block(i);
            }
        }];
        [vc addAction:alert];
    }
    
    if (popover) {
        
        
        popover.sourceView = view;
        
        popover.sourceRect=CGRectMake((CGRectGetWidth(popover.sourceView.bounds)-2)*0.5f,
                                      (CGRectGetHeight(popover.sourceView.bounds)-2)*0.5f,
                                      2,2);
        popover.permittedArrowDirections = UIPopoverArrowDirectionAny;
        UIWindow *window = kApplicationWindow;
        if (window.rootViewController.presentedViewController) {
            [window.rootViewController.presentedViewController presentViewController:vc animated:YES completion:nil];
        }else
        {
            [window.rootViewController presentViewController:vc animated:YES completion:nil];
        }
        
    }else
    {
        UIWindow *window = kApplicationWindow;
        [TipTool showMasErrorTip:@"popover异常" superView:window];
    }
    
}
+(void)showiPhoneSheetViewWithTitle:(NSString*)title message:(NSString*)message  btns:(NSArray*)btns  block:(void(^)(NSInteger index))block
{
    UIAlertController *vc = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleActionSheet];
    
    
    for (int i = 0; i<btns.count; i++) {
        NSString *btnText = btns[i];
        NSInteger type = UIAlertActionStyleDefault;
        if ([btnText isEqualToString:@"取消"]) {
            type = UIAlertActionStyleDestructive;
        }else if ([btnText isEqualToString:@"删除"])
        {
           type = UIAlertActionStyleDestructive;
        }
        
        
        UIAlertAction *alert = [UIAlertAction actionWithTitle:btnText style:type handler:^(UIAlertAction * _Nonnull action) {
            if (block) {
                block(i);
            }
        }];
        [vc addAction:alert];
    }
    UIWindow *window = kApplicationWindow;
    if (window.rootViewController.presentedViewController) {
        [window.rootViewController.presentedViewController presentViewController:vc animated:YES completion:nil];
    }else
    {
        [window.rootViewController presentViewController:vc animated:YES completion:nil];
    }
}

+ (void)showSystemAlertWithTitle:(NSString *)title msg:(NSString *)msg buttons:(NSArray *)buttons block:(void(^)(NSInteger index))block{
    UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:(UIAlertControllerStyleAlert)];
    for (int i = 0; i<buttons.count; i++) {
        NSString *btnText = buttons[i];
        NSInteger type = UIAlertActionStyleDefault;
        if ([btnText isEqualToString:@"取消"]) {
            type = UIAlertActionStyleDestructive;
        }else if ([btnText isEqualToString:@"删除"]){
            type = UIAlertActionStyleDestructive;
        }
        UIAlertAction *alert = [UIAlertAction actionWithTitle:btnText style:type handler:^(UIAlertAction * _Nonnull action) {
            if (block) {
                block(i);
            }
        }];
        [alertVC addAction:alert];
    }
    UIWindow *window = kApplicationWindow;
    if (window.rootViewController.presentedViewController) {
        [window.rootViewController.presentedViewController presentViewController:alertVC animated:YES completion:nil];
    }else{
        [window.rootViewController presentViewController:alertVC animated:YES completion:nil];
    }
}

+ (void)showCustomAlertWithStype:(DGGTipStyle)style image:(NSString *)image title:(NSString *)title msg:(NSString *)msg cancelTitle:(NSString *)cancelTitle
                    confirmTitle:(NSString *)confirmTitle
                           block:(void(^)(NSInteger index))block{
    
    AlertView *alertView = [[AlertView alloc] init];
    NSString *alertImage = image;
    switch (style) {
        case DGGTipStyle_Successful:
            alertImage = [DLThemeAdapter shareInstance].isDark ? @"img_popup_chenggong_dark" : @"img_popup_chenggong";
            break;
        case DGGTipStyle_Error:
            alertImage = [DLThemeAdapter shareInstance].isDark ? @"img_popup_cuowu_dark" : @"img_popup_cuowu";
            break;
        case DGGTipStyle_Warning:
            alertImage = [DLThemeAdapter shareInstance].isDark ? @"img_popup_jinggao_dark" : @"img_popup_jinggao";
            break;
        case DGGTipStyle_Prompt:
            alertImage = [DLThemeAdapter shareInstance].isDark ? @"img_popup_tishi_dark" : @"img_popup_tishi";
            break;
        case DGGTipStyle_Custom:
            alertImage = image;
            break;
        default:
            break;
    }
    alertView.titleFont = [UIFont systemFontOfSize:18.0 weight:UIFontWeightBold];
    alertView.messageFont = [UIFont systemFontOfSize:14.0];
    [alertView showImage:alertImage title:title message:msg cancelTitle:cancelTitle confirmTitle:confirmTitle cancel:^{
        if (block) {
            block(0);
        }
    } confirm:^{
        if (block) {
            block(1);
        }
    }];
}

+ (void)showLoadingViewWithSuperView:(UIView *)superVie
                        loadingColor:(UIColor *)loadingColor
                             message:(NSString *)message
                              radius:(CGFloat)radius{
    [TipTool hideTipView];
    [Hud sharedHud].loadingView = [[DLLoadingRunTip alloc] init];
    [Hud sharedHud].loadingView.loadingColor = loadingColor;
    [[Hud sharedHud].loadingView showLoadingMessage:message superView:superVie radius:radius];
}
+ (void)showLoadingAllViewWithSuperView:(UIView *)superVie
                           loadingColor:(UIColor *)loadingColor
                                message:(NSString *)message
                                 radius:(CGFloat)radius{
    [TipTool hideTipView];
    [Hud sharedHud].loadingView = [[DLLoadingRunTip alloc] init];
    [Hud sharedHud].loadingView.loadingColor = loadingColor;
    [[Hud sharedHud].loadingView showBigLoadingMessage:message superView:superVie radius:radius];
        
}

+ (void)showLoadingAllViewToastWithSuperView:(UIView *)superView{
    [TipTool hideTipView];
    [Hud sharedHud].loadingView = [[DLLoadingRunTip alloc] init];
    [Hud sharedHud].loadingView.isToast = YES;
    [Hud sharedHud].loadingView.loadingColor = [UIColor whiteColor];
    [[Hud sharedHud].loadingView showBigLoadingMessage:nil superView:superView radius:24];
}

+ (void)showLoadingAllViewToast{
    [TipTool hideTipView];
    [Hud sharedHud].loadingView = [[DLLoadingRunTip alloc] init];
    [Hud sharedHud].loadingView.isToast = YES;
    [Hud sharedHud].loadingView.loadingColor = [UIColor whiteColor];
    [[Hud sharedHud].loadingView showBigLoadingMessage:nil superView:kApplicationWindow radius:24];
}


+ (void)showLoadingViewWithoutSingTonWithSuperView:(UIView *)superVie
                        loadingColor:(UIColor *)loadingColor
                             message:(NSString *)message
                              radius:(CGFloat)radius{
    
    [TipTool hideLoadingViewInSuperView:superVie];
    DLLoadingRunTip *loadingView = [[DLLoadingRunTip alloc] init];
    loadingView.loadingColor = loadingColor;
    [loadingView showLoadingMessage:message superView:superVie radius:radius];
}
+ (void)showLoadingAllViewWithoutSingTonWithSuperView:(UIView *)superVie
                           loadingColor:(UIColor *)loadingColor
                                message:(NSString *)message
                                 radius:(CGFloat)radius{
    
    [TipTool hideLoadingViewInSuperView:superVie];
    DLLoadingRunTip *loadingView = [[DLLoadingRunTip alloc] init];
    loadingView.loadingColor = loadingColor;
    [loadingView showBigLoadingMessage:message superView:superVie radius:radius];
    
}

+ (void)hideLoadingViewInSuperView:(UIView *)superVie{
    for (UIView *subView in superVie.subviews) {
        if ([subView isKindOfClass:DLLoadingRunTip.class]) {
            [subView removeFromSuperview];
        }
    }
}

@end

